﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ADONETDataServicesExtension.Utils;
using System.Reflection;

namespace ADONETDataServicesExtension.Providers
{
    public class ResourceProperty : FrameworkEncapsulatedType<object>
    {
        internal const string FrameworkTypeName = "System.Data.Services.Providers.ResourceProperty";

        public ResourceProperty(object resourceProperty)
            : base(resourceProperty)
        {
        }

        public int Kind
        {
            get
            {
                return ReflectionHelper.GetProperty<int>(FrameworkTypeName, "Kind", FrameworkObject);
            }
            set
            {
                ReflectionHelper.SetProperty(FrameworkTypeName, "Kind", FrameworkObject, value);
            }
        }

        public string MimeType
        {
            get
            {
                return ReflectionHelper.GetProperty<string>(FrameworkTypeName, "MimeType", FrameworkObject);
            }
        }

        public PropertyInfo PropertyInfo
        {
            get
            {
                return ReflectionHelper.GetProperty<PropertyInfo>(FrameworkTypeName, "PropertyInfo", FrameworkObject);
            }
            set
            {
                ReflectionHelper.SetField(FrameworkTypeName, "propertyInfo", FrameworkObject, value);
            }
        }

        public ResourceContainer ResourceContainer
        {
            get
            {
                return ReflectionHelper.Convert(ReflectionHelper.GetProperty(FrameworkTypeName, "ResourceContainer", FrameworkObject), frameworkValue => new ResourceContainer(frameworkValue));
            }
        }

        public string Name
        {
            get
            {
                return ReflectionHelper.GetProperty<string>(FrameworkTypeName, "Name", FrameworkObject);
            }
        }

        public ResourceType ResourceType
        {
            get
            {
                return ReflectionHelper.Convert(ReflectionHelper.GetProperty(FrameworkTypeName, "ResourceType", FrameworkObject), frameworkValue => new ResourceType(frameworkValue));
            }
        }

        public int TypeKind
        {
            get
            {
                return ReflectionHelper.GetProperty<int>(FrameworkTypeName, "TypeKind", FrameworkObject);
            }
        }
    }
}
